import { request } from "../../utils/request";
import config from "../../utils/config";

const app = getApp();
Page({
    data: {
        picUrl: config.picUrl,
        custom: {},
        list:[
            {title:'盒装',url:'/pages/add_juben_old/add_detail?type=1',color:"#ee833b"},
            {title:'城市限定',url:'',color:"#ffc821"},
            {title:'城市独家',url:'',color:"#76abdc"},
        ],
        user:{}
    },
    onLoad(options) {
        this.setData({
            custom:wx.getMenuButtonBoundingClientRect(),
            user:wx.getStorageSync('userInfo')
        })
    },
    nav(e){
        var {url,index} = e.currentTarget.dataset
        var timeStamp = Date.now()
        var info = wx.getStorageSync('userInfo')
        if(index >= 1){
            wx.showToast({
              title: '未获取发行方授权暂不支持本功能',
              icon:"none"
            })
            return false;
        }
        if(this.data.user.expire != 1){
            if(info.authentication_type == 3){
                //没做任何认证，提示先去认证。
                wx.showModal({
                    title:'提示',
                    content:"您还未进行进行会员充值，请先充值会员",
                    showCancel:false,
                    confirmText:"充值会员",
                    success:res=>{
                        if(res.confirm) {
                            wx.navigateTo({url: '/pages/member_recharge/member_recharge'})
                        }
                    }
                })

            }else if(info.authentication_type == 4){
                wx.showModal({
                    title:'提示',
                    content:"您还未进行进行会员充值，请先充值会员",
                    showCancel:false,
                    confirmText:"充值会员",
                    success:res=>{
                        if(res.confirm) {
                            wx.navigateTo({url: '/pages/member_recharge2/member_recharge'})
                        }
                    }
                })
            }
        }else{
            wx.navigateTo({url})
        }
    }
})